package com.rs.game;

import com.rs.cache.loaders.ObjectDefinitions;

@SuppressWarnings("serial")
public class WorldObject extends WorldTile {

	private int id;
	private int type;
	private int rotation;
	private int life;
	private static int index;

	public WorldObject(int id, int type, int rotation, WorldTile tile) {
		super(tile.getX(), tile.getY(), tile.getPlane());
		this.id = id;
		this.type = type;
		this.rotation = rotation;
		this.life = 1;
	}

	public WorldObject(int id, int type, int rotation, int x, int y, int plane) {
		super(x, y, plane);
		this.id = id;
		this.type = type;
		this.rotation = rotation;
		this.life = 1;
	}

	public WorldObject(int id, int type, int rotation, int x, int y, int plane,
			int life) {
		super(x, y, plane);
		this.id = id;
		this.type = type;
		this.rotation = rotation;
		this.life = life;
	}

	public WorldObject(WorldObject object) {
		super(object.getX(), object.getY(), object.getPlane());
		this.id = object.id;
		this.type = object.type;
		this.rotation = object.rotation;
		this.life = object.life;
	}
	
	/*public WorldObject getSpawnedObject(WorldTile tile) {
		if (spawnedObjects == null)
			return null;
		for (WorldObject object : spawnedObjects)
			if (object.getX() == tile.getX() && object.getY() == tile.getY()
					&& object.getPlane() == tile.getPlane())
				return object;
		return null;
	}*/
	
	public static int index() {
		return index;
	}

	public WorldObject index(int index) {
		WorldObject.index = index;
		return this;
	}
	
	public int getId() {
		return id;
	}

	public int getType() {
		return type;
	}
	
	public void setId(int id) {
		this.id = id;
		}
	
	public int getRotation() {
		return rotation;
	}

	public void setRotation(int rotation) {
		this.rotation = rotation;
	}

	public int getLife() {
		return life;
	}

	public void setLife(int life) {
		this.life = life;
	}

	public void decrementObjectLife() {
		this.life--;
	}

	public ObjectDefinitions getDefinitions() {
		return ObjectDefinitions.getObjectDefinitions(id);
	}
}
